<?php

declare(strict_types=1);

class CustomNumericScoreTheme extends NumericScoreTheme 
{

  public function get_voter(Image $image)
    {
        global $user, $page;
        $i_image_id = $image->id;
        if (is_string($image->numeric_score)) {
            $image->numeric_score = (int)$image->numeric_score;
        }
        $i_score = $image->numeric_score;

        $html = "
      Gem Score: $i_score";

          if (!$user->is_anonymous()) {
        $html .= "
			<p><form action='".make_link("numeric_score_vote")."' method='POST'>
			".$user->get_auth_html()."
			<input type='hidden' name='image_id' value='$i_image_id'>
			<input type='hidden' name='vote' value='up'>
			<input type='submit' value='Gem'>
			</form>

			<form action='".make_link("numeric_score_vote")."' method='POST'>
			".$user->get_auth_html()."
			<input type='hidden' name='image_id' value='$i_image_id'>
			<input type='hidden' name='vote' value='null'>
			<input type='submit' value='Remove Vote'>
			</form>

			<form action='".make_link("numeric_score_vote")."' method='POST'>
			".$user->get_auth_html()."
			<input type='hidden' name='image_id' value='$i_image_id'>
			<input type='hidden' name='vote' value='down'>
			<input type='submit' value='Coal'>
			</form>
		";
        }
        if ($user->can(Permissions::EDIT_OTHER_VOTE)) {
            $html .= "
			<form action='".make_link("numeric_score/remove_votes_on")."' method='POST'>
			".$user->get_auth_html()."
			<input type='hidden' name='image_id' value='$i_image_id'>
			<input type='submit' value='Remove All Votes'>
			</form>";
        }
        if ($user->can(Permissions::VIEW_OTHER_VOTE)) {
			      $html .= "
      <br><div id='votes-content'>
				<a
					href='".make_link("numeric_score_votes/$i_image_id")."'
					onclick='$(\"#votes-content\").load(\"".make_link("numeric_score_votes/$i_image_id")."\"); return false;'
				>See All Votes</a>
			</div>
			";
        }
        $page->add_block(new Block("Post Score", $html, "left", 20));
    }
}

